package cn.silver.module.system.controller;

import cn.silver.framework.core.model.DictModel;
import cn.silver.framework.mybatis.controller.BaseController;
import cn.silver.framework.openapi.model.Result;
import cn.silver.module.system.bean.DeptPostBean;
import cn.silver.module.system.domain.SysDeptPost;
import cn.silver.module.system.param.DeptPostParam;
import cn.silver.module.system.service.ISysDeptPostService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.stream.Collectors;

/**
 * 个人收藏信息Controller
 *
 * @author Silver.Zhou
 */

@RestController
@RequiredArgsConstructor
@Tag(name = "系统管理-部门管理-岗位信息")
@RequestMapping("/system/dept/post")
public class SysDeptPostController extends BaseController<ISysDeptPostService, SysDeptPost, DeptPostParam, DeptPostBean> {
    @Override
    @Resource
    public void setBaseService(ISysDeptPostService baseService) {
        this.setCode("system:dept");
        this.setTitle("系统管理-部门管理-岗位信息");
        this.baseService = baseService;
    }

    @GetMapping("/dict")
    @Operation(summary = "字典信息查询", description = "获取字典信息")
    public Result<List<DictModel>> listDict(@ModelAttribute DeptPostParam entity) {
        List<DeptPostBean> resultList = this.baseService.selectList(entity);
        List<DictModel> dictModels = resultList.stream().map(item -> new DictModel(item.getPostName(), item.getId(), item.getDeptId())).collect(Collectors.toList());
        return Result.ok(dictModels);
    }
}
